<?php include_once 'common/header.php'; ?>
<!-- admin_main -->
<div class="admin_main">
    <!-- Admin_top end -->
    <?php include_once 'common/borrow_left.php'; ?>
    <?php
    $borrow_check = array(0 => '未检查', 1 => '数据已检查');
    ?>
    <!-- Admin_Left End -->
    <div class="admin_right">
        <div class="admin_right_title"><strong>贷款管理</strong> >> 编辑借款标信息</div>
        <form id="borrowForm" name="borrowForm">
            <input type="hidden" id="id" name="id" value="<?php echo $borrow['id']; ?>" />
            <div class="admin_borrow">
                <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#dcdcdc">
                    <tr>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">标题：</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="title" id="title" value="<?php echo $borrow['title']; ?>" size="30" />

                        </td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">项目编号：</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="project_number" id="project_number" value="<?php echo $borrow['project_number']; ?>" /></td>

                        <td bgcolor="#FFFFFF" width="100px;" align="right">标种：
                        </td>
                        <td bgcolor="#FFFFFF"><select id="ftype" name="ftype">
                                <?php foreach ($borrow_type as $key => $value) { ?><option value="<?php echo $key; ?>" <?php if ($borrow['ftype'] == $key) { ?> selected="selected"<?php } ?> ><?php echo $value; ?></option><?php } ?></select>
                        </td>

                    </tr>

                    <tr>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">期限：
                        </td>
                        <td bgcolor="#FFFFFF"><select id="time_limit" name="time_limit">
                                <?php foreach ($borrow_time_limit as $key => $value) { ?><option value="<?php echo $key; ?>" <?php if ($borrow['time_limit'] == $key) { ?> selected="selected"<?php } ?> ><?php echo $value; ?></option><?php } ?></select>
                        </td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">金额：</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="account" id="account" value="<?php echo $borrow['account']; ?>" /></td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">利率：</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="apr" id="apr" value="<?php echo round($borrow['apr'], 1); ?>" />%</td>

                    </tr>
                    <tr>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">还款方式：
                        </td>
                        <td bgcolor="#FFFFFF"><select id="style" name="style">
                                <?php foreach ($borrow_style as $key => $value) { ?><option value="<?php echo $key; ?>" <?php if ($borrow['style'] == $key) { ?> selected="selected"<?php } ?> ><?php echo $value; ?></option><?php } ?></select>
                        </td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">最小投标金额：
                        </td>
                        <td bgcolor="#FFFFFF">
                            <input type="text" name="lowest_account" id="lowest_account" value="<?php echo $borrow['lowest_account']; ?>" />
                        </td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">最大投标金额：
                        </td>
                        <td bgcolor="#FFFFFF">
                            <input type="text" name="most_account" id="most_account" value="<?php echo $borrow['most_account']; ?>" />
                        </td>

                    </tr>
                    <tr>
                        <!--
                        <td bgcolor="#FFFFFF" width="100px;" align="right">是否奖励：</td>
                        <td bgcolor="#FFFFFF"><input type="checkbox" name="award" id="award"  value="2"  <?php if ($borrow['award'] == 2) { ?>checked="checked"<?php } ?> /></td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">奖励比例：</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="funds" id="funds" value="<?php echo $borrow['funds']; ?>" /></td>
                        -->


                        <td bgcolor="#FFFFFF" width="100px;" align="right">有效时间：</td>
                        <td bgcolor="#FFFFFF" colspan="5">
                            <select id="valid_time" name="valid_time">
                                <?php foreach ($borrow_valid_time as $key => $value) { ?>
                                    <option value="<?php echo $key; ?>" <?php if ($key == $borrow['valid_time']) { ?>selected="selected"<?php } ?> ><?php echo $value; ?></option>
                                <?php } ?></select></td>



                    </tr>
                    <tr>
                        <td  bgcolor="#FFFFFF" width="100px;" align="right">开放投资时间：
                        </td>
                        <td  bgcolor="#FFFFFF">
                            <input type="text" id="auto_verify_time" name="auto_verify_time" class="pubinput" style="width: 150px;" value="<?php if ($borrow['auto_verify_time'] > 0) {
                                    echo date('Y-m-d H:i', $borrow['auto_verify_time']); ?> <?php } ?>"  onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd HH:mm'})" readonly="readonly" />
                        </td>
                        <td  bgcolor="#FFFFFF" width="120px;" align="right">
<?php if ($borrow['ftype'] == 7) { ?>担保机构<?php } else { ?>抵（质）押物<?php } ?>
                            ：
                        </td>

                        <td  bgcolor="#FFFFFF">
                            <select id="guarantee_id" name="guarantee_id">
                                <option value="0">--请选择机构--</option>
                                <?php foreach ($guarantee_list as $gv) { ?>
                                    <option value="<?php echo $gv['id']; ?>" <?php if ($gv['id'] == $borrow['guarantee_id']) { ?>selected="selected"<?php } ?> ><?php echo $gv['alias']; ?></option>
<?php } ?></select>
                        </td>

                        <td  bgcolor="#FFFFFF" width="100px;" align="right">数据是否检查：
                        </td>

                        <td  colspan="3" bgcolor="#FFFFFF">
                            <span style="color:blue;"><?php echo $borrow_check[$borrow['is_check']]; ?></span>
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">是否推荐：</td>
                        <td bgcolor="#FFFFFF"><input type="checkbox" name="recommend_id" id="recommend_id"  value="1"  <?php if ($borrow['recommend_id'] == 1) { ?>checked="checked"<?php } ?> />

                        </td>
                        <td bgcolor="#FFFFFF" width="100px;" align="right">平台手续费</td>
                        <td bgcolor="#FFFFFF"><input type="text" name="borrow_fee" id="borrow_fee" value="<?php echo $borrow['borrow_fee']; ?>" />%</td>

                        <td bgcolor="#FFFFFF" width="100px;" align="right">抵押物：</td>
                        <td bgcolor="#FFFFFF"><?php echo $borrow['cltroGoods'];?></td>

                    </tr>
                </table>
                <div class="borrow_content_wrap">
                    <h3>项目LOGO</h3>
                    <input type="file" name="thumbnail" id="thumbnail" />
                    <img width="175" height="185" src="/<?php echo BORROW_IMG;?>/<?php echo $borrow['thumbnail']; ?>"/>
                    注意：建议尺寸大小为：175*185
                </div>

                <div class="borrow_content_wrap">
                    <h3>项目概述</h3>
                    <p><script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
                        <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.js"></script>
                        <script type="text/javascript" charset="utf-8">
                                var editor = new baidu.editor.ui.Editor();
                                editor.render('content');  //editor为编辑器容器的id
                        </script>
                        <textarea name="content" id="content" style="width:965px">
<?php echo $borrow['content']; ?>
                        </textarea></p>
<!--                    <h3>融资用途</h3>-->
<!--                    <p style="margin-left:40px;"><textarea id="fuse" rows="8" cols="100" >--><?php //echo $borrow['fuse']; ?><!--</textarea></p>-->
                    <h3>还款来源：</h3>
                    <p style="margin-left:40px;"><textarea name="repay_from" id="repay_from" rows="8" cols="100" ><?php echo $borrow['repay_from']; ?></textarea></p>
                    <h3>风控措施：</h3>
                    <p style="margin-left:40px;"><textarea name="risk_manage" id="risk_manage" rows="8" cols="100" ><?php echo $borrow['risk_manage']; ?></textarea></p>
                    <h3>评审决议：</h3>
                    <p style="margin-left:40px;">
                        <textarea rows="8" cols="100" id="verify_remark" name="verify_remark"><?php echo $borrow['verify_remark']; ?></textarea>
                    </p>
                </div>

                <div class="payment_btm" style="margin-top:20px;">
                    <input type="button" onclick="borrowSubmit();" value="提  交" class="btn_b" />
                </div>

            </div>
        </form>
    </div>
    <!-- Admin_Right End -->
</div>
<!-- admin_main end -->
<script type="text/javascript">
    $(document).ready(function () {
        //是否勾选天标
        $("#is_day").click(function () {
            if ($("#is_day").is(":checked")) {
                $("#time_limit_day").show();
                $("#time_limit").attr("disabled", true);
                $("#time_limit").val(1);
            } else {
                $("#time_limit_day").hide();
                $("#time_limit").attr("disabled", false);
            }
        });
        //是否启用定向标
        $("#is_dxb").click(function () {
            if ($("#is_dxb").is(":checked")) {
                $("#dxb_pwd").attr("disabled", false);
            } else {
                $("#dxb_pwd").attr("disabled", true);
            }
        });
        $("#borrow_btn").click(function () {
            $("#borrowForm").submit();
            $("#borrowForm").attr("disabled", true);
        });
    });
    function borrowSubmit() {
        var options = {
            url: '/ychadmin/borrow/edit/',
            //clearForm :true,
            //resetForm :true,
            //contentType:"multipart/form-data",
            beforeSubmit: checkForm,
            dataType: "json",
            type: "post",
            success: function (ret) {
                if (ret.msg == '1') {
                    alert("操作成功");
                    window.location.reload();
                } else {
                    alert(ret.msg);
                }

            }
        };
        $("#borrowForm").ajaxSubmit(options);
        return false;
    }

    function checkForm() {
        var err = '';
        if (IsDouble($('#account').val()) == false) {
            err = '请填写有效的借款金额';
        } else if ($('#account').val() < 500) {
            err = '借款金额必须大于500';
        } else if ($('#account').val() > 5000000) {
            err = '借款金额必须小于500w';
        } else if (IsDouble($('#apr').val()) == false) {
            err = '请填写有效的年利率';
        } else if ($('input[name="award"]:checked').val() == 2) {
            if (IsDouble($('#funds').val()) == false) {
                err = '请填写有效的奖励';
            }
        } else if ($('#title').val() == '') {
            err = '请填写借款标题';
        } else if ($('#content').val() == '') {
            err = '请填写借款内容';
        }
        if (err == '') {
            return true;
        } else {
            alert(err);
            return false;
        }
    }
</script>
<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
</body>
</html>

